package com.hsy.crm.web.domain.entity;

import com.hsy.crm.web.domain.cm.Validate;
import com.hsy.crm.web.domain.vo.asyn.InStoreDetail;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 单据明细
 */
@Table(name="t_order_detail")
public class OrderDetail extends BaseEntity {

    @Transient
    private Long storeProductId;

    /**
     * 主表id
     */
    @Validate
    @Column(length = 20)
    private Long orderId;

    /**
     * 退货时
     * 明细对应的明细的明细id
     */
    @Column(length = 20)
    private Long orderDetailId;

    /**
     * 批次号
     */
    @Column(length = 20)
    private String batchNo;

    /**
     * 生产日期
     */
    @Column(length = 20)
    private Long productionDate;

    /**
     * 保质期
     */
    @Column(length = 11)
    private Integer shelfLife;

    /**
     * 同主表orderType
     */
    @Validate
    @Column(length = 11)
    private Integer orderType;

    @Validate
    @Column(length = 20)
    private Long productId;

    @Validate
    @Column(length = 20)
    private Long companyId;

    @Validate
    @Column(length = 20)
    private Long storeId;

    @Validate
    @Column(length = 20)
    private Long unitId;

    @Validate
    @Column(length = 20)
    private Long number;

    @Validate
    @Column(length = 20)
    private Long price;

    @Validate
    @Column(length = 20)
    private Long sort;

    /**
     * 优惠平摊金额  一般为0  整个订单有优惠金额时为必填项
     */
    @Column(length = 20)
    private Long percentPrice;

    /**
     * 采购费用平摊金额  一般为0  整个订单有采购费用时为必填项
     */
    @Column(length = 20)
    private Long purPercentPrice;

    /**
     * 折扣率 %
     */
    @Validate
    @Column(length = 11)
    private Integer discountRate;

    /**
     * 折扣金额
     */
    @Validate
    @Column(length = 11)
    private Long discountMoney;

    /**
     * 折后金额
     */
    @Validate
    @Column(length = 11)
    private Long discountPrice;

    @Column(length = 20)
    private String remarks;

    public Long getStoreProductId() {
        return storeProductId;
    }

    public void setStoreProductId(Long storeProductId) {
        this.storeProductId = storeProductId;
    }

    public Long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        this.orderId = orderId;
    }

    public Long getOrderDetailId() {
        return orderDetailId;
    }

    public void setOrderDetailId(Long orderDetailId) {
        this.orderDetailId = orderDetailId;
    }

    public String getBatchNo() {
        return batchNo;
    }

    public void setBatchNo(String batchNo) {
        this.batchNo = batchNo;
    }

    public Long getProductionDate() {
        return productionDate;
    }

    public void setProductionDate(Long productionDate) {
        this.productionDate = productionDate;
    }

    public Integer getShelfLife() {
        return shelfLife;
    }

    public void setShelfLife(Integer shelfLife) {
        this.shelfLife = shelfLife;
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Long getProductId() {
        return productId;
    }

    public void setProductId(Long productId) {
        this.productId = productId;
    }

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public Long getStoreId() {
        return storeId;
    }

    public void setStoreId(Long storeId) {
        this.storeId = storeId;
    }

    public Long getUnitId() {
        return unitId;
    }

    public void setUnitId(Long unitId) {
        this.unitId = unitId;
    }

    public Long getNumber() {
        return number;
    }

    public void setNumber(Long number) {
        this.number = number;
    }

    public Long getPrice() {
        return price;
    }

    public void setPrice(Long price) {
        this.price = price;
    }

    public Long getSort() {
        return sort;
    }

    public void setSort(Long sort) {
        this.sort = sort;
    }

    public Long getPercentPrice() {
        return percentPrice;
    }

    public void setPercentPrice(Long percentPrice) {
        this.percentPrice = percentPrice;
    }

    public Long getPurPercentPrice() {
        return purPercentPrice;
    }

    public void setPurPercentPrice(Long purPercentPrice) {
        this.purPercentPrice = purPercentPrice;
    }

    public Integer getDiscountRate() {
        return discountRate;
    }

    public void setDiscountRate(Integer discountRate) {
        this.discountRate = discountRate;
    }

    public Long getDiscountMoney() {
        return discountMoney;
    }

    public void setDiscountMoney(Long discountMoney) {
        this.discountMoney = discountMoney;
    }

    public Long getDiscountPrice() {
        return discountPrice;
    }

    public void setDiscountPrice(Long discountPrice) {
        this.discountPrice = discountPrice;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public InStoreDetail toInStoreDetail(){
        InStoreDetail detail = new InStoreDetail();
        detail.setId(this.getId());
        detail.setProductId(this.getProductId());
        detail.setCompanyId(this.getCompanyId());
        detail.setStoreId(this.getStoreId());
        detail.setUnitId(this.getUnitId());
        detail.setNumber(this.getNumber());
        detail.setPrice(this.getPrice());
        detail.setPercentPrice(this.getPercentPrice());
        detail.setPurPercentPrice(this.getPurPercentPrice());
        detail.setOrderType(this.getOrderType());
        return detail;
    }
}
